package com.mxpio.erp.asset.service.impl;

import com.mxpio.erp.common.asset.service.BorrowOutMaterialFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mxpio.erp.common.asset.entity.BorrowApplyLine;
import com.mxpio.erp.common.asset.service.BorrowApplyLineService;
import com.mxpioframework.system.service.impl.BaseServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

@Service
public class BorrowApplyLineServiceImpl extends BaseServiceImpl<BorrowApplyLine> implements BorrowApplyLineService{
    @Autowired
    private BorrowOutMaterialFlowService borrowOutMaterialFlowService;
    @Override
    @Transactional(readOnly = true)
    public void handleBorrowApplyLinesReturnedQuantity(List<BorrowApplyLine> borrowApplyLines) {
        if (borrowApplyLines!=null&&borrowApplyLines.size()>0){//查询仓单行 已执行数量
            for (BorrowApplyLine line:borrowApplyLines){
                BigDecimal completeQuantity = borrowOutMaterialFlowService.getReturnedSumQuantityByLineNo(line.getBizNo(), line.getLineNo());
                line.setActualQuantity(completeQuantity);
            }
        }
    }
}
